package com.one.common.view.adapter;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import java.util.ArrayList;

/**
 * creator: zhulunjun
 * time:    2017/9/8
 * describe: fragment 的 viewpager适配器
 */

public class PagerFragmentAdapter<T extends Fragment> extends FragmentPagerAdapter {

    private  ArrayList<T> fragments;

    public PagerFragmentAdapter(FragmentManager fm, ArrayList<T> fragments) {
        super(fm);
        this.fragments = fragments;
    }

    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return fragments.size();
    }
}
